//this file cleans enrollment outcome data

global direc "[YOUR PATH HERE]"
global data "${direc}/data"


********************************************************************************
**COMPLETIONS DATA**
********************************************************************************

use "${data}/clean_ipeds_completion.dta", clear
		drop _merge
	
//keep only bachelor, associate, and certificate totals (this drops graduate degrees)
drop if awlevel < 1
drop if awlevel > 5
	rename awlevel deg
	
//fill in any missing control var based on previous year controls
sort unitid file_year
by unitid : egen new_cont = mode(control)
	drop control 
	rename new_cont control

//fill in any missing locales based on previous year locales
sort unitid file_year
by unitid : egen new_loc = max(locale)
	drop locale 
	rename new_loc locale
gen urban = (locale == 11 | locale == 12 | locale == 13)

//fill in any missing states based on previous year states
sort unitid file_year
by unitid : egen new_st = mode(st_fips)
	drop st_fips 
	rename new_st st_fips
	
	
//generate flag for minority serving institutions
foreach s in hbcu pbi annhi tribal aanapii hsi nanti{
	sort unitid file_year
	by unitid : egen new`s' = max(`s')
		drop `s'
		rename new`s' `s'
}
gen msu = 0
foreach s in hbcu pbi annhi tribal aanapii hsi nanti{
	replace msu = 1 if (`s')
}

save "${data}/outcomes_completions.dta", replace

